import { useI18n } from '/@/hooks/web/useI18n';
import { BasicColumn, BasicTableProps, FormProps } from '/@/components/Table';
import {  pmMaterialListData } from '/@/api/material/bom/pmMaterial';

const { t } = useI18n('sys.empUser');

const modalProps = {
  title: t('材料清单选择'),
};

const searchForm: FormProps = {
  baseColProps: { lg: 6, md: 8 },
  labelWidth: 80,
  showResetButton:false,
  schemas: [
    // {
    //   label: t('工程名称'),
    //   field: 'name',
    //   component: 'Input',
    //   show: false,
    // },
    {
      label: t('工程编码'),
      field: 'pcode',
      component: 'Input',
      show: false,
    },
    // {
    //   label: t('sno'),
    //   field: 'sno',
    //   component: 'Input',
    //   ifShow: false,
    // },
    {
      label: t('物料编码'),
      field: 'mcode',
      component: 'Input',
    },
    {
      label: t('物料名称'),
      field: 'mname',
      component: 'Input',
    },
    {
      label: t('创建时间'),
      field: 'createtime',
      component: 'DatePicker',
      componentProps: {
        format: 'YYYY-MM-DD HH:mm',
        showTime: { format: 'HH:mm' },
      },
    },
    {
      label: t('是否主材'),
      field: 'bmain',
      component: 'Select',
      componentProps: {
        dictType: 'sys_yes_no',
      },
      ifShow: false,
    },
  ],
};

const tableColumns: BasicColumn[] = [
  {
    title: t('创建时间'),
    dataIndex: 'createtime',
    key: 'a.createtime',
    sorter: true,
    width: 150,
    align: 'left',
    slot: 'firstColumn',
    format: 'YYYY-MM-DD HH:mm',
  },
  {
    title: t('工程名称'),
    dataIndex: 'name',
    key: 'a.name',
    sorter: true,
    width: 300,
    align: 'left',
  },
  {
    title: t('工程编码'),
    dataIndex: 'pcode',
    key: 'a.pcode',
    sorter: true,
    width: 130,
    align: 'left',
  },
  // {
  //   title: t('sno'),
  //   dataIndex: 'sno',
  //   key: 'a.sno',
  //   sorter: true,
  //   width: 130,
  //   align: 'left',
  // },
  {
    title: t('设计变更编码'),
    dataIndex: 'fdno',
    key: 'a.fdno',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('物料编码'),
    dataIndex: 'mcode',
    key: 'a.mcode',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('物料名称'),
    dataIndex: 'mname',
    key: 'a.mname',
    sorter: true,
    width: 300,
    align: 'left',
  },
  {
    title: t('规格型号'),
    dataIndex: 'mstd',
    key: 'a.mstd',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('数量'),
    dataIndex: 'num',
    key: 'a.num',
    sorter: true,
    width: 80,
    align: 'right',
  },
  {
    title: t('单位'),
    dataIndex: 'unit',
    key: 'a.unit',
    sorter: true,
    width: 80,
    align: 'center',
  },
  {
    title: t('是否主材'),
    dataIndex: 'bmain',
    key: 'a.bmain',
    sorter: true,
    width: 100,
    align: 'center',
    dictType: 'sys_yes_no',
    fixed:'right'
  },
];

const tableProps: BasicTableProps = {
  api: pmMaterialListData,
  beforeFetch: (params) => {
    params['isAll'] = true;
    return params;
  },
  columns: tableColumns,
  formConfig: searchForm,
  rowKey: 'mcode',
};

export default {
  modalProps,
  tableProps,
  itemCode: 'mcode',
  itemName: 'mname',
};
